/**
 * 周评-面谈准备
 *
 */
import React from 'react';

import { Form } from 'antd';
import { Collapse } from '@/molecules';
import { useCollapse } from '@/hooks';
import { QuestionListFormItem } from '@/containers';
import { usePrepareQuestionsForm, useAssessSetting, usePrepareAlert } from '../hooks';
import { AssessTask, AssessAbilityResult, PrepareAlert } from '../containers';

const { Panel } = Collapse;

function InterviewPreparingW({ form, data = {} }) {
    usePrepareQuestionsForm(form, data?.interviewPrepareVO);
    const { activeKey, onChange } = useCollapse(['1', '2', '3'], []);
    const { w = {} } = useAssessSetting(data);
    const { message, renderButton } = usePrepareAlert('W', data);
    return (
        <div>
            <PrepareAlert message={message} renderButton={renderButton} />
            <Collapse bordered={false} activeKey={activeKey} onChange={onChange}>
                {w.showTask && (
                    <Panel header="任务情况" key="1">
                        <AssessTask data={data} />
                    </Panel>
                )}
                {w.showAssess && (
                    <Panel header="能力评估" key="2">
                        <AssessAbilityResult data={data?.assessWeekly} levels={data?.assessAbility?.levels} />
                    </Panel>
                )}
                <Panel header="面谈自定义问题" key="3">
                    {form.getFieldDecorator('questions')(
                        <QuestionListFormItem disabled style={{ width: 900 }} form={form} />
                    )}
                </Panel>
            </Collapse>
        </div>
    );
}

export default Form.create({})(InterviewPreparingW);
